package com.fh.shop.api.mq.producer;

import com.fh.shop.api.mq.config.MQConstant;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HelloProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

//    public void sendDirectMsg(String msg) {
//        rabbitTemplate.convertAndSend(MQConstant.TestDirect.EX, MQConstant.TestDirect.ROUTE_KEY, msg);
//    }

    public void sendDirectMsg(String ex, String routeKey, String msg) {
        rabbitTemplate.convertAndSend(ex, routeKey, msg);
    }

    public void sendFanoutMsg(String msg) {
        rabbitTemplate.convertAndSend(MQConstant.TestFanout.EX, null, msg);
    }

    public void sendTopicMsg(String ex, String routeKey, String msg) {
        rabbitTemplate.convertAndSend(ex, routeKey, msg);
    }
}
